<template>
	<view class="user-wallet-qh-page">
		<view class="header-box">
			<image src="../../static/images/bg_1.png" mode="widthFix" class="bg-img"></image>
			<view class="text1">我的积分</view>
			<view class="text2">{{myScore}}</view>
			<view class="text3">
				<u-icon name="volume" size="28" color="#fff"></u-icon>
				<text class="text">积分可不定时兑换线上商品</text>
			</view>
		</view>
		<view class="main-box">
			<view class="list-box">
				<view class="item" v-for="item in dataList" :key="item.id">
					<view class="top-bar">
						<view class="label">{{item.type_text}}</view>
						<view class="value">{{item.status_text}}{{item.integral}}</view>
					</view>
					<view class="row-between date">
						<view>{{item.utime}}</view>
						<view>{{item.remark}}</view>
					</view>
				</view>
				<loading-footer :status="status"></loading-footer>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getMyScoreList,
		getMyScore
	} from '@/api/store';
	import {
		loadingFun
	} from '../../../utils/tools';
	import {
		loadingType
	} from '../../../utils/type';
	export default {
		data() {
			return {
				page: 1,
				status: loadingType.LOADING,
				dataList: [],
				myScore: 0,
			};
		},

		components: {},
		props: {},

		onLoad: function(options) {
			this.getDataList();

			getMyScore().then(res => {
				if (res.code != 1) return;
				this.myScore = res.data.user_integral
			})
		},


		methods: {
			clear() {
				this.page = 1;
				this.status = loadingType.LOADING;
				this.dataList = []
			},
			async getDataList() {
				const data = await loadingFun(getMyScoreList, this.page, this.dataList, this.status);
				if (data) {
					this.page = data.page;
					this.dataList = data.dataList;
					this.status = data.status;
				}
			}
		}
	};
</script>
<style lang="scss" scoped>
	.user-wallet-qh-page {
		// height: 100vh;
		overflow: hidden;

		.header-box {
			width: 750rpx;
			height: 240rpx;
			position: relative;
			padding: 56rpx 20rpx 0;

			.bg-img {
				width: 100%;
				height: auto;
				position: absolute;
				top: 0;
				left: 0;
				z-index: -1;
			}

			.text1 {
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #FFFFFF;
				line-height: 28rpx;
			}

			.text2 {
				font-family: PingFang SC, PingFang SC;
				font-weight: 600;
				font-size: 60rpx;
				color: #FFFFFF;
				line-height: 60rpx;
				margin-top: 16rpx;
			}

			.text3 {
				margin-top: 20rpx;

				.text {
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 24rpx;
					color: #FFFFFF;
					line-height: 24rpx;
					margin-left: 12rpx;
				}
			}
		}

		.main-box {
			width: 100%;
			height: calc(100vh - 240rpx - env(safe-area-inset-bottom));
			position: relative;
			overflow: auto;
			background: #fff;
			border-radius: 20rpx 20rpx 0rpx 0rpx;
			display: flex;
			flex-direction: column;

			.tab-box {
				width: 750rpx;
				background: #FFFFFF;
				border-radius: 20rpx 20rpx 0rpx 0rpx;
				display: flex;

				.tab {
					width: 50%;
					height: 120rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 32rpx;
					color: #999999;
					line-height: 32rpx;
				}

				.is-active {
					font-weight: 600;
					font-size: 36rpx;
					color: #373737;
				}
			}

			.list-box {
				flex: 1;
				width: 710rpx;
				overflow: auto;
				margin: 0 auto;

				.item {
					padding: 32rpx 0;
					border-bottom: 1rpx solid #E6E6E6;

					.top-bar {
						display: flex;
						justify-content: space-between;
						align-items: center;

						.label {
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							font-size: 32rpx;
							color: #333333;
							line-height: 32rpx;
						}

						.value {
							font-family: PingFang SC, PingFang SC;
							font-weight: 600;
							font-size: 32rpx;
							color: #333333;
							line-height: 32rpx;
						}
					}

					.content {
						width: 710rpx;
						height: 72rpx;
						background: #F6F6F6;
						border-radius: 5rpx;
						display: flex;
						align-items: center;
						padding: 0 24rpx;
						margin-top: 24rpx;

						.avatar {
							width: 48rpx;
							height: 48rpx;
							border-radius: 50%;
						}

						.text {
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							font-size: 24rpx;
							color: #333333;
							line-height: 24rpx;
							margin-left: 15rpx;
						}
					}

					.date {
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #999999;
						line-height: 24rpx;
						margin-top: 24rpx;
					}
				}
			}
		}
	}
</style>